{******************************Version: MPL 1.1*********************************
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Initial Developer : Fajar Khairil
*
* Portions created by the Initial Developer are Copyright (C) 2010 - 2011
* the Initial Developer. All Rights Reserved.
*
********************************************************************************
* This File is Part of HdFramework OPF Library
* Copyright (C) 2010 - 2011 HdFramework Developer Team
*
* Unit : HadeBaseDataSet
* Description : Interface and base class for HadeDataSet(Accessor) Concreate Class
* Author: - Fajar Khairil
*		  - 
*******************************************************************************}
unit hadebasedataset; 

{$mode objfpc}{$H+}

interface

uses
  Classes,
  SysUtils,
  hadeconnectionmanager,
  hadeMapping,
  hadebaseobject;
Type
  IHadeDataSet = interface
    ['{DD7EA13F-9E06-4E62-93F6-171E6ABD674D}']
    function Count: integer;

    procedure SetSQL(AValue: TStrings);
    function GetSQL: TStrings;

    procedure SetValueByName(const AProp: string; const AVal: variant);
    function getValueByName(const AColName: string): variant;

    procedure setStringByName(const AProp: string; const AVal: string);
    function getStringByName(const AColName: string): string;

    function getIntegerByName(const AColName: string): integer;
    procedure setIntegerByName(const AProp: string; const AVal: integer);

    function getDoubleByName(const AColName: string): double;
    procedure setDoubleByName(const AProp: string; const AVal: double);

    function getDateTimeByName(const AColName: string): TDateTime;
    procedure setDateTimeByName(const AProp: string; const AVal: TDateTime);

    //function getStreamByName(const AColName: string): TStream;
    //procedure setStreamByName(const AProp: string; const AVal: TStream);

    property SQL: TStrings read GetSQL write SetSQL;

    procedure Open;
    procedure Close;
    procedure ExecSQL;
    Procedure ExecuteMultiple(Asql:String);

    Property ValueByName[Const AColName:string]:Variant read getValueByName write setValueByName;
    Property StringByName[Const AColName:string]:String read getStringByName write setStringByName;
    Property IntegerByName[Const AColName:string]:Integer read getIntegerByName write setIntegerByName;
    Property DoubleByName[Const AColName:string]:Double read getDoubleByName write setDoubleByName;
    Property DateTimeByName[Const AColName:string]:TDateTime read getDateTimeByName write setDateTimeByName;
    //Property StreamByName[Const AColName:string]:Stream read getStreamByName write setStreamByName;

    //Navigation Behaviour
    procedure Next;
    procedure First;
    procedure Last;
    procedure Prior;
    function EOF: boolean;

    function getLastInsertID(ATableName:String):int64;
  end;

  { THadeBaseDataSet }

  THadeBaseDataSet = class(THadeBaseObject)
  protected
    FConnection:THadeConnection;
    FMappingManager:THadeMappingManager;
  public
    constructor Create(const AConnection: THadeConnection);virtual;
  end;

implementation

{ THadeBaseDataSet }

constructor THadeBaseDataSet.Create(const AConnection: THadeConnection);
begin
  FConnection := AConnection;
  FMappingManager:=GHadeMappingManager.find(AConnection.ConnectionName);
end;

end.

